package com.scy.demo.controller;

import com.scy.demo.service.IDemoService;
import com.scy.edu.mvcframework.annotations.MyAutowired;
import com.scy.edu.mvcframework.annotations.MyController;
import com.scy.edu.mvcframework.annotations.MyRequestMapping;
import com.scy.edu.mvcframework.annotations.MySecurity;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @author 司晨雨
 * @date 2020/5/30 19:50
 * @description
 */
@MyController
@MyRequestMapping("/demo")
@MySecurity({"zhangsan","lisi"})
public class DemoController {

    @MyAutowired
    private IDemoService demoService;

    /**
     *
     * @param request
     * @param response
     * @param userName
     * @return
     */
    @MyRequestMapping("/query")
    public  String query(HttpServletRequest request, HttpServletResponse response, String userName){
        return  demoService.getName(userName);
    }

    @MyRequestMapping("/handle01")
    @MySecurity({"zhangsan"})
    public void handle01(HttpServletRequest request, HttpServletResponse response, String userName) throws IOException {
        response.getWriter().write("current user is :"+userName);
    }

}
